
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false,use_css=false,use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}
if(use_gebi && document.all){x=AnchorPosition_getPageOffset(document.all[anchorname],'Left');y=AnchorPosition_getPageOffset(document.all[anchorname], 'Top');
}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffset(o,'Left');y=AnchorPosition_getPageOffset(o, 'Top');}else if(use_css){x=AnchorPosition_getPageOffset(document.all[anchorname],'Left');y=AnchorPosition_getPageOffset(document.all[anchorname],'Top');
}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}
x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffset(el,ot){
   if(el.getBoundingClientRect){return el.getBoundingClientRect()[ot.toLowerCase()]+Math.max(document.documentElement['scroll'+ot],document.body['scroll'+ot])-document.documentElement['client'+ot];
   }else{
       var o=el['offset'+ot];while((el=el.offsetParent)!=null){o+=el['offset'+ot];}
       return o;}}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffset(el, 'Left')-document.body.scrollLeft;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffset(el, 'Top')-document.body.scrollTop;}
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?'':'0')+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0||d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+'';var result='';var i_format=0;var c='';var token='';var y=date.getYear()+'';var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,KK,K,kk,k;var value=new Object();if(y.length < 4){y=''+(y-0+1900);}value['y']=''+y;value['yyyy']=y;value['yy']=y.substring(2,4);value['M']=M;value['MM']=LZ(M);value['MMM']=MONTH_NAMES[M-1];value['NNN']=MONTH_NAMES[M+11];value['d']=d;value['dd']=LZ(d);value['E']=DAY_NAMES[E+7];value['EE']=DAY_NAMES[E];value['H']=H;value['HH']=LZ(H);if(H==0){value['h']=12;}else if(H>12){value['h']=H-12;}else {value['h']=H;}value['hh']=LZ(value['h']);if(H>11){value['K']=H-12;} else{value['K']=H;}value['k']=H+1;value['KK']=LZ(value['K']);value['kk']=LZ(value['k']);if(H > 11){value['a']='PM';}else{value['a']='AM';}value['m']=m;value['mm']=LZ(m);value['s']=s;value['ss']=LZ(s);while(i_format<format.length){c=format.charAt(i_format);token='';while((format.charAt(i_format)==c)&&(i_format<format.length)){token+=format.charAt(i_format++);}if(value[token]!=null){result=result+value[token];}else{result=result+token;}}return result;}
function _isInteger(val){var digits='1234567890';for (var i=0; i < val.length; i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for (var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length<minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+'';format=format+'';var i_val=0;var i_format=0;var c='';var token='';var token2='';var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm='';var i;while(i_format < format.length){c=format.charAt(i_format);token='';while((format.charAt(i_format)==c)&&(i_format<format.length)){token+=format.charAt(i_format++);}
if(token=='yyyy' || token=='yy' || token=='y'){if(token=='yyyy'){ x=4;y=4; }if(token=='yy'){x=2;y=2;}if(token=='y'){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val+=year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=='MMM'||token=='NNN'){month=0;for (i=0; i<MONTH_NAMES.length; i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){
if(token=='MMM'||(token=='NNN'&&i>11)){month=i+1;if(month>12){month-=12;}i_val+=month_name.length;break;}}}if((month<1)||(month>12)){return 0;}}else if(token=='EE'||token=='E'){for (i=0; i<DAY_NAMES.length; i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=='MM'||token=='M'){month=_getInt(val,i_val,token.length,2);
if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=='dd'||token=='d'){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=='hh'||token=='h'){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=='HH'||token=='H'){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}
else if(token=='KK'||token=='K'){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=='kk'||token=='k'){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=='mm'||token=='m'){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=='ss'||token=='s'){ss=_getInt(val,i_val,token.length,2);
if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=='a'){if(val.substring(i_val,i_val+2).toLowerCase()=='am'){ampm='AM';}else if(val.substring(i_val,i_val+2).toLowerCase()=='pm'){ampm='PM';}else {return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else {i_val+=token.length;}}}if(i_val != val.length){ return 0; }if(month==2){if(((year%4==0)&&(year%100!=0))||(year%400==0)){if(date > 29){return 0;}}
else{if(date>28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date>30){return 0;}}if(hh<12 && ampm=='PM'){ hh=hh-0+12; }else if(hh>11 && ampm=='AM'){ hh-=12; }var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst=new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0; i<checkList.length; i++){var l=window[checkList[i]];
for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}
function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type == 'WINDOW'){coordinates = getAnchorWindowPosition(anchorname);}else{coordinates = getAnchorPosition(anchorname);}this.x = coordinates.x;this.y = coordinates.y;}
function PopupWindow_setSize(width,height){this.width = width;this.height = height;}
function PopupWindow_populate(contents){this.contents = contents;this.populated = false;}
function PopupWindow_setUrl(url){this.url = url;}
function PopupWindow_setWindowProperties(props){this.windowProperties = props;}
function PopupWindow_CheckSize(){
   try{
       var vcbCalendarIFrame=GetElem('cbCalendarIFrame');var vcbCalendarConteiner=GetElem('cbCalendarConteiner');var vcbCalendarNavigationTable=GetElem('cbCalendarNavigationTable');var vcbCalendarBody=GetElem('cbCalendarBody');
       var newWidth=Math.max(this.conteinerWidth, vcbCalendarConteiner.offsetWidth-2);
       if(vcbCalendarNavigationTable.offsetWidth>vcbCalendarConteiner.offsetWidth && vcbCalendarNavigationTable.offsetWidth > newWidth){
           newWidth=vcbCalendarNavigationTable.offsetWidth+1;}
       if(vcbCalendarBody.offsetWidth>vcbCalendarConteiner.offsetWidth && vcbCalendarBody.offsetWidth>newWidth){newWidth=vcbCalendarBody.offsetWidth+1;}
       this.conteinerWidth = newWidth;
           try{vcbCalendarIFrame.style.width=newWidth+'px';}catch(e){}
           vcbCalendarConteiner.style.width=newWidth+'px';vcbCalendarNavigationTable.style.width=newWidth+'px';vcbCalendarBody.style.width=newWidth+'px';
   }catch(e){}
}
function PopupWindow_refresh(){
    if(this.divName != null){
       this.divNode=GetElem(this.divName);
       if(this.divNode){this.divNode.innerHTML=this.contents;this.checkSize();}
       }else{if(this.popupWindow != null && !this.popupWindow.closed){if(this.url!=''){this.popupWindow.location.href=this.url;}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();}this.popupWindow.focus();}}}
function PopupWindow_showPopup(anchorname){
   this.getXYPosition(anchorname);this.x += 17;this.checkConteiner();
   if(!this.populated && (this.contents != '')){this.populated = true;this.refresh();}
   if(this.divName != null){
       var c=GetElem(this.divName);if(!c)return;
       c.style.left=this.x+'px';c.style.top=this.y+'px';c.style.display='block';this.checkSize();
   }else{if(this.popupWindow==null || this.popupWindow.closed){if(this.x<0){this.x=0;}if(this.y<0){this.y=0;}
if(screen && screen.availHeight){if((this.y+this.height)>screen.availHeight){try{this.y=screen.availHeight-this.height;}catch(ex){}}}if(screen && screen.availWidth){if((this.x+this.width)>screen.availWidth){this.x = screen.availWidth-this.width;}}var avoidAboutBlank=window.opera || (document.layers && !navigator.mimeTypes['*']) || navigator.vendor=='KDE' || (document.childNodes && !document.all && !navigator.taintEnabled);
try{this.popupWindow=window.open(avoidAboutBlank?'':'about:blank','window_'+anchorname,this.windowProperties+',width=150,height=175,screenX='+this.x+',left='+this.x+',screenY='+this.y+',top='+this.y+'');}catch(ex){}}this.refresh();}}
function PopupWindow_hidePopup(){
    if (this.divName!=null){try{GetElem(this.divName).style.display='none';}catch(e){}}else{if(this.popupWindow && !this.popupWindow.closed){this.popupWindow.close();this.popupWindow=null;}}}
function PopupWindow_isClicked(e){
   var t;
   if(this.divName!=null){
        if(this.use_layers){
            var clickX=e.pageX;var clickY=e.pageY;t=document.layers[this.divName];
            if((clickX>t.left)&&(clickX<t.left+t.clip.width)&&(clickY>t.top)&&(clickY<t.top+t.clip.height)){return true;}else{return false;}
        }else if(document.all){
            t=window.event.srcElement;
            while(t.parentElement!=null){if(t.id==this.divName){return true;}t=t.parentElement;}return false;
        }else if(this.use_gebi&&e){
           t=e.target||e.originalTarget;
           while(t.parentNode!=null){if(t.id==this.divName){return true;}t=t.parentNode;}return false;}
       return false;}
   return false;}
function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled && !this.isClicked(e)){this.hidePopup();}}
function PopupWindow_hidePopupWindows(e){for (var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i] != null){var p = popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PopupWindow_attachListener(){
   if(document.layers){document.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener = document.onmouseup;
   if(window.popupWindowOldEventListener!=null){document.onmouseup=function(){window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();};
   }else{document.onmouseup = PopupWindow_hidePopupWindows;}}
function GetElem(id){if(document.getElementById){return document.getElementById(id)}else if(document.all){return document.all[this.divName]}else if(document.layers){return document.layers[this.divName];}}
function PopupWindow(){
   if(!window.popupWindowIndex){window.popupWindowIndex=0;}if(!window.popupWindowObjects){window.popupWindowObjects=new Array();}if(!window.listenerAttached){window.listenerAttached=true;PopupWindow_attachListener();}
   this.index = popupWindowIndex++;popupWindowObjects[this.index]=this;
   this.UA=new function(){this.userAgent=navigator.userAgent;this.IS_OPERA=Boolean(this.userAgent.match(/Opera[\/ ](\d+)\.?(\d+)?/));this.IS_IE=Boolean(this.userAgent.match(/MSIE (\d+)\.(\d+)/)&&!this.IS_OPERA);};
   this.divName = null;this.popupWindow = null;this.width=0;this.height=0;this.populated = false;this.visible = false;this.autoHideEnabled = true;this.contents = '';this.url='';
   this.windowProperties='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,alwaysRaised=no,dependent,titlebar=no';
   this.checkConteiner=function(){
       if(this.divName != null && !GetElem(this.divName)){
           if(this.UA.IS_IE && document.readyState!='complete')return;
           var c=document.createElement('div');c.id=this.divName;c.style.position='absolute';c.style.display='none';c.style.backgroundColor='#fff';c.style.zIndex=1000;
           try{document.body.appendChild(c);}catch(e){}}};
   if(arguments.length>0){this.type='DIV';this.divName = arguments[0];
   }else{this.type='WINDOW';}
   this.use_gebi = false;this.use_css = false;this.use_layers = false;
   if(document.getElementById){this.use_gebi=true;}else if(document.all){this.use_css=true;}else if(document.layers){this.use_layers=true;}else{this.type='WINDOW';}
   this.conteinerWidth = 140;this.getXYPosition=PopupWindow_getXYPosition;this.populate=PopupWindow_populate;this.setUrl=PopupWindow_setUrl;this.setWindowProperties=PopupWindow_setWindowProperties;this.refresh=PopupWindow_refresh;this.checkSize=PopupWindow_CheckSize;
   this.showPopup=PopupWindow_showPopup;this.hidePopup=PopupWindow_hidePopup;this.setSize=PopupWindow_setSize;this.isClicked=PopupWindow_isClicked;this.hideIfNotClicked=PopupWindow_hideIfNotClicked;}
function CalendarPopup(){
    var c;c=new PopupWindow(arguments[0]);
    c.monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');c.monthAbbreviations = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');c.dayHeaders=new Array('Su','Mo','Tu','We','Th','Fr','Sa');
    c.returnFunction='CP_tmpReturnFunction';c.weekStartDay=0;c.displayType='date';c.currentDate= null;c.isShowNavigationDropdowns=false;
    window.CP_calendarObject=null;window.CP_targetInput=null;window.CP_dateFormat='MM/dd/yyyy';
    c.todayText=formatDate(new Date(),window.CP_dateFormat);
    c.showCalendar=CP_showCalendar;c.hideCalendar=CP_hideCalendar;c.refreshCalendar=CP_refreshCalendar;c.getCalendar=CP_getCalendar;c.select=CP_select;
    return c;}
function CP_tmpReturnFunction(y,m,d){
    if(window.CP_targetInput != null){
        var dt = new Date(y,m-1,d,0,0,0);
        window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
        
        //try{window.CP_targetInput.fireEvent('onchange', event);}catch(e){}
        try{
            if(window.CP_targetInput.dispatchEvent){
                var evt = document.createEvent("HTMLEvents");
                evt.initEvent('change', true, true);
                window.CP_targetInput.dispatchEvent(evt);
            }else if(window.CP_targetInput.fireEvent){
                var evt = document.createEventObject();
                window.CP_targetInput.fireEvent('onchange', evt);
            }
        }catch(e){}

    }else{
        alert('Use setReturnFunction() to define which function will get the clicked results!');
    }
}
function CP_hideCalendar(){
   if(arguments.length > 0){window.popupWindowObjects[arguments[0]].hidePopup();
   }else{this.hidePopup();}}
function CP_refreshCalendar(index){
   var calObject = window.popupWindowObjects[index];
   if(arguments.length>1){calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
   }else{calObject.populate(calObject.getCalendar());}
   calObject.refresh();}
function CP_showCalendar(anchorname){
   if(arguments.length>1){
       if(arguments[1]==null||arguments[1]==''){this.currentDate=new Date();
       }else{this.currentDate=new Date(parseDate(arguments[1]));}}
   this.populate(this.getCalendar());this.showPopup(anchorname);}
function CP_select(inputobj, linkname, format){
   var selectedDate=(arguments.length>3)?arguments[3]:null;
   if(!window.getDateFromFormat){alert('calendar.select: To use this method you must also include date.js for date formatting');return;}
   if(this.displayType!='date' && this.displayType != 'week-end'){alert('calendar.select: This function can only be used with displayType "date" or "week-end"');return;}
   if(inputobj.type!='text' && inputobj.type!='hidden' && inputobj.type!='textarea'){alert('calendar.select: Input object passed is not a valid form input object');window.CP_targetInput=null;return;}
   if(inputobj.disabled){return;}
   window.CP_targetInput=inputobj;window.CP_calendarObject=this;this.currentDate=null;
   var time=0;
   if(selectedDate!=null){time = getDateFromFormat(selectedDate,format)
   }else if(inputobj.value!=''){
       var tmpVal = inputobj.value;
       if(tmpVal.search(/[ ]/ig)!=-1)tmpVal=tmpVal.split(' ')[0];
       time = getDateFromFormat(tmpVal,format);}
   if(selectedDate!=null || inputobj.value!=''){
       if(time==0){this.currentDate=null;}else{this.currentDate=new Date(time);}}
   window.CP_dateFormat = format;this.showCalendar(linkname);}
function CP_getCalendar(){
   var now = new Date();
   var result = '';
   if(this.displayType=='date' || this.displayType=='week-end'){
        if(this.currentDate==null){this.currentDate=now;}
        if(arguments.length > 0){var month=arguments[0];}else{var month = this.currentDate.getMonth()+1;}
        if(arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]){var year=arguments[1];}else{var year=this.currentDate.getFullYear();}
        var daysinmonth=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
        if(((year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ){daysinmonth[2] = 29;}
        var current_month = new Date(year,month-1,1);
        var display_year = year;var display_month=month;var display_date=1;var weekday=current_month.getDay();var offset=0;
        offset=(weekday>=this.weekStartDay)?weekday-this.weekStartDay: 7-this.weekStartDay+weekday;
        if(offset > 0){
            display_month--;
            if(display_month<1){display_month=12;display_year--;}
            display_date=daysinmonth[display_month]-offset+1;}
        var next_month=month+1;var next_month_year=year;
        if(next_month>12){next_month=1;next_month_year++;}
        var last_month=month-1;var last_month_year=year;
        if(last_month<1){last_month=12;last_month_year--;}
        var refresh='CP_refreshCalendar';var refreshLink='javascript:'+refresh;
        if(this.UA.IS_IE)result+='<iframe id="cbCalendarIFrame" src="/modules/DWT/BlankPage.html" style="position: absolute; left: 0px; border: 0px; display:block; width: '+(this.conteinerWidth+2)+'px; height: 160px;"></iframe>';
        result+='<div id="cbCalendarConteiner" style="position: absolute; z-index: 1001; border: 1px solid #808080; width: '+this.conteinerWidth+'px; height: 185px; background-color: #fff;">';
        result+='<table id="cbCalendarNavigationTable" style="line-height: normal; width:100%; height: 16px; margin:0px; border-collapse: inherit;"  cellspacing="0" cellpadding="0">';
            result+='<tbody style="border:none;">';
                result+='<tr>';
                    var commonNavStl='padding: 0px; margin: 0px; background-color: #d3d3d3;';
                    var commonNavTextStl='text-align: center;font-weight: bold;font-size: 8pt;cursor: pointer;';
                    result+='<td style="'+commonNavStl+'cursor:font-weight: bold;font-size: 8pt;default;width: 5px;">&nbsp;</td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'width:7px;"><a style="text-decoration: none; color: #000;" href="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</a></td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'"><span style="cursor: default;font-size: 8pt; font-family: Arial;">'+String(this.monthNames[month-1]).replace(/ /g, '&nbsp;')+'</span></td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'width:7px"><a style="text-decoration: none; color: #000;" href="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</a></td>';
                    result+='<td style="'+commonNavStl+'font-weight: bold;font-size: 8pt;text-align: center;font-weight: bold;font-size: 8pt;cursor:default; width:3px">&nbsp;</td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'width:7px;"><a style="text-decoration: none; color: #000;" href="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</a></td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'width:30px;"><span style="cursor: default;font-size: 8pt; font-family: Arial;">'+year+'</span></td>';
                    result+='<td style="'+commonNavStl+commonNavTextStl+'width:7px;"><a style="text-decoration: none; color: #000;" href="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</a></td>';
                    result+='<td style="padding: 0px; margin: 0px; background-color: #d3d3d3;font-weight: bold;font-size: 8pt;cursor:default;width: 5px;">&nbsp;</td>';
                result+='</tr>';
            result+='</tbody>';
       result+='</table>';
       result+='<table id="cbCalendarBody" style="line-height: normal; width:100%; height: 142px; border:none; margin:0px; border-collapse: inherit;" cellspacing="0" cellpadding="0">';
           result+='<tr>';
           for (var j=0;j<7;j++){
              result+='<td style="padding: 0px; margin: 0px; text-align:center;color:#000; font-size:8pt; font-family: Arial;cursor: default;border: none;border-bottom: 1px solid #C0C0C0;border-top: 1px solid #C0C0C0;">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</td>';
           }
           result+='</tr>';
           for(var row=1;row<=6;row++){
               result+='<tr>';
                   for(var col=1;col<=7;col++){
                   var disabled=false;var dateClass="";var TDstyle="";var style="";
                   if((display_month==this.currentDate.getMonth()+1)&&(display_date==this.currentDate.getDate())&&(display_year==this.currentDate.getFullYear())){
                       dateClass="cbCurrentDate";TDstyle="background-color:#d3d3d3;border:1px solid #336699;font-weight:bold;";style="color:#000;";
                   }else if(display_month==month){dateClass = "cbCurrentMonthDate";TDstyle = "border: 1px solid #fff;";style = "color:#000;";
                   }else{dateClass = "cbOtherMonthDate";TDstyle = "border: 1px solid #fff;";style = "color:#808080;";}
                   var selected_date=display_date;var selected_month=display_month;var selected_year=display_year;
                   if(this.displayType=="week-end"){
                       var d=new Date(selected_year,selected_month-1,selected_date,0,0,0,0);d.setDate(d.getDate()+(7-col));selected_year = d.getYear();
                       if(selected_year < 1000){selected_year += 1900;}selected_month = d.getMonth()+1;selected_date = d.getDate();}
                   result+='<td class="'+dateClass+'" style="'+TDstyle+'text-align: center; cursor: pointer; padding: 0px; margin: 0px;" onmouseover="f_calendarCellMouseOver(event, this);" onmouseout="f_calendarCellMouseOut(event, this);" onclick="try{'+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+"}catch(ex){}try{CP_hideCalendar('"+this.index+"');}catch(e){}"+'">';
                   result+='<a style="'+style+'display: block;text-align: right;width: 12px;font-size: 8pt;font-family: Arial; text-decoration: none;margin: auto;" href="javascript:try{'+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+"}catch(ex){}try{CP_hideCalendar('"+this.index+"');}catch(e){}"+'">'+display_date+'</a>';
                   result+='</td>';
                   display_date++;
                   if(display_date>daysinmonth[display_month]){display_date=1;display_month++;}if(display_month>12){display_month=1;display_year++;}}
               result+='</tr>';}
           var current_weekday=now.getDay()-this.weekStartDay;if(current_weekday < 0){current_weekday += 7;}
           result+='</table>';}
       result+='<div style="line-height: normal; padding-top: 3px; margin-top: 3px;border-top: 1px solid #C0C0C0;text-align: center;cursor: pointer;height: 20px;" onclick="try{ '+this.returnFunction+"('"+now.getFullYear()+"','"+(now.getMonth()+1)+"','"+now.getDate()+"');}catch(k){}try{CP_hideCalendar('"+this.index+"');}catch(e){}"+'">';
       result+='<a style="color:#000;text-decoration: none;font-size:8pt;font-family:Arial;" href="javascript: try{ '+this.returnFunction+"('"+now.getFullYear()+"','"+(now.getMonth()+1)+"','"+now.getDate()+"');}catch(k){}try{CP_hideCalendar('"+this.index+"');}catch(e){}"+'">'+this.todayText+'</a>';
       result+='</div>';
   result+='</div>';return result;}
function f_calendarCellMouseOver(event,v_this){v_this.style.backgroundColor='#b0d7e6';v_this.style.borderColor='#b0d7e6';}
function f_calendarCellMouseOut(event,v_this){
    if(v_this.className=='cbCurrentMonthDate'){v_this.style.backgroundColor='#fff'; v_this.style.borderColor='#fff';
    }else if(v_this.className=='cbCurrentDate'){v_this.style.backgroundColor='#d3d3d3'; v_this.style.borderColor='#336699';
    }else if(v_this.className=='cbOtherMonthDate'){v_this.style.backgroundColor='#fff';v_this.style.borderColor='#fff';}}

var v_cal; try{v_cal=new CalendarPopup('cb_calendar_conteiner');} catch(v_e) {}

///////////////////////////Add Row/////////////////////////////
var iddong=40;

function addRow(tableID) {

    var table = document.getElementById(tableID);

    var rowCount = table.rows.length;
  
    iddong+=4;
    var colCount = table.rows[0].cells.length;
   if(rowCount<=10){
	   var row = table.insertRow(rowCount);
    for(var i=0; i<colCount; i++) {
    	
        var newcell = row.insertCell(i);

   
      if(i==0||i==1)
        	newcell.innerHTML="<INPUT type=\"text\" /><span class=\"2\"><a onclick=\"try{if(v_cal){v_cal.select(this.parentNode.previousSibling,'"+rowCount+i+"','MM/dd/yyyy');}}catch(e){}return false;\" id="+rowCount+i+" name="+rowCount+i+"> <img src=\"./img/calendar.png\" alt=\"Calendar\" border=\"0\" style=\"vertical-align: middle;\"></a> </span>";
        
      else if(i==2||i==3) newcell.innerHTML="<INPUT type=\"text\" />";
      else newcell.innerHTML=" <a onclick=\"deleteRow(this.parentNode.parentNode.rowIndex)\"><img id="+rowCount+" alt=\"image\" src=\"./img/Delete.png\" width=\"20\" height=\"20\"></a>";
      //alert(newcell.childNodes);
        switch(newcell.childNodes[0].type) {
            case "text":
                    newcell.childNodes[0].value = "";
                    newcell.childNodes[0].name=iddong+i;
           
                    break;       
        }
    }
}else { alert('Don\'t add max row 10 ');}
}
/////////////////////Delete Row////////////////////////////
function deleteRow(i){
	 var hi= confirm("Are you sure you wwant to delete this record?");
	    if (hi== true){
	    	
	    	document.getElementById('dataTable').deleteRow(i);
	    	var table = document.getElementById('dataTable');
	    	var rowCount = table.rows.length;
	    	rowCount--;
	    	
	    	
	    }
    
}

function isDate(dtStr){
	  var daysInMonth = DaysArray(12);
	  var pos1=dtStr.indexOf(dtCh);
	  var pos2=dtStr.indexOf(dtCh,pos1+1);
	  var strDay=dtStr.substring(0,pos1);
	  var strMonth=dtStr.substring(pos1+1,pos2);
	  var strYear=dtStr.substring(pos2+1);
	  strYr=strYear;
	  if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	  if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	  for (var i = 1; i <= 3; i++) {
	   if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	  }
	  month=parseInt(strMonth);
	  day=parseInt(strDay);
	  year=parseInt(strYr);
	  if (pos1==-1 || pos2==-1){
	   //alert("The date format should be : mm/dd/yyyy")
	   return false;
	  }
	  if (strMonth.length<1 || month<1 || month>12){
	   //alert("Please enter a valid month")
	   return false;
	  }
	  if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
	   //alert("Please enter a valid day")
	   return false;
	  }
	  if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	   //alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
	   return false;
	  }
	  if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
	   //alert("Please enter a valid date")
	   return false;
	  }
	 return true;
	 }

